<template>
  <div>
    <script id="editor" type="text/plain"></script>
  </div>
</template>
<script>
  export default {
    name: 'ue',
    data () {
      return {
        editor: null
      }
    },
    props: {
      value: '',
      config: {}
    },
    mounted () {
      const _this = this
      this.editor = window.UE.getEditor('editor', this.config)
      window.UE.Editor.prototype._bkGetActionUrl = window.UE.Editor.prototype.getActionUrl
      window.UE.Editor.prototype.getActionUrl = function (action) {
//        if (action === 'uploadimage' || action === 'uploadfile') {
        return 'http://localhost:9000/operFile/upload'
//        } else {
//          return window.UE.Editor.prototype._bkGetActionUrl.call(_this, action)
//        }
      }
      this.editor.addListener('ready', function () {
        _this.editor.setContent(_this.value)
      })
    },
    methods: {
      getUEContent () {
        return this.editor.getContent()
      }
    },
    destroyed () {
      this.editor.destroy()
    }
  }
</script>
